<f:view contentType="text/html" xmlns="http://www.w3.org/1999/xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets">
  <ui:fragment
    rendered="#{not empty applicationConfiguration.piwikUrl and not empty applicationConfiguration.piwikIdSite}">
    <!-- Piwik -->
    <script type="text/javascript">
      //<![CDATA[
      var username = "#{identity.accountUsername}";
      if (#{identity.loggedIn} == false) {
        username = "anonymous";
      }

      var _paq = _paq || [];
      _paq.push(['setCustomVariable', '1', "Visit", username, "visit"]);
      _paq.push(['setCustomVariable', '2', "View page", username, "page"]);
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u="#{applicationConfiguration.piwikUrl}/";
        _paq.push(['setTrackerUrl', u+'piwik.php']);
        _paq.push(['setSiteId', #{applicationConfiguration.piwikIdSite}]);
        var d=document, g=d.createElement('script'),
          s=d.getElementsByTagName('script')[0];
        g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js';
        s.parentNode.insertBefore(g,s);
      })();
      //]]>
    </script>
    <noscript><p><img src="#{applicationConfiguration.piwikUrl}/piwik.php?idsite=#{applicationConfiguration.piwikIdSite}&amp;rec=1"
      style="border:0;" alt="" /></p></noscript>
    <!-- End Piwik Code -->
  </ui:fragment>

  <ui:remove>
  <!-- jQuery will be loaded automatically if there are RichFaces tags, but
       we need jQuery on other pages. Also, jQuery needs to be loaded in head
       so that we can use jQuery(document).ready(). -->
  </ui:remove>
  <h:outputScript library="org.richfaces" name="jquery.js" target="head"/>
  <script type="text/javascript" src="#{request.contextPath}/resources/assets/bootstrap.min.js"></script>
  <script type="text/javascript" src="#{request.contextPath}/resources/assets/zanata.js"></script>
  <h:outputScript library="script" name="components-script.js"/>
  <h:outputScript library="webjars" name="${webjars.signalsJS}"/>
  <h:outputScript library="webjars" name="${webjars.crossroadsJS}"/>
</f:view>
